package com.voicechat.firstmet.net.service;

import android.util.Log;

import com.voicechat.firstmet.bean.CommBean;
import com.voicechat.firstmet.bean.CommentBean;
import com.voicechat.firstmet.bean.CoummunityNotice;
import com.voicechat.firstmet.bean.PostBean;
import com.voicechat.firstmet.bean.Result;
import com.voicechat.firstmet.net.Params;

import rx.Observable;

/**
 * @ProjectName: FirstMet
 * @Package: com.voicechat.firstmet.net.service
 * @ClassName: CommunityService
 * @Description: 社区service
 * @Author: ljp
 * @CreateDate: 2018/10/9 13:41
 * @Version: 1.0
 */
public class CommunityService extends BaseService {
    /**
     * 热门类型
     */
    public interface HOT_TYPE {
        String HOT_ANCHOR_TYPE= "1";//主播
        String HOT_POST_TYPE = "2";//帖子
        String HOT_TIME_TYPE = "3";//时段推荐
        String HOT_ADVE_TYPE = "4";//广告位
    }
    /**
     * 点赞类型
     */
    public interface LIKE_TYPE {
        String LIKE_POST_TYPE= "1";//帖子点赞
        String LIKE_COMM_TYPE = "2";//评论点赞
    }

    /**
     * @return
     * @method
     * @description 社区页面公告信息
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<CoummunityNotice> communityNotice(String token, String equipmentId) {
        Params params = new Params();
        params.put("token", token);
        params.put("equipmentId", equipmentId);
        //Log.i("LoginService", "" + params.toString());
        return sNetInterface.communityNotice(params).compose(applySchedulers());
    }

    /**
     * @return
     * @method
     * @description 社区页面信息（banner、实时推荐、广告位、热门帖子）
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<CommBean> communityHotInfo(String token, String equipmentId,String touristId) {
        Params params = new Params();
        params.put("token", token);
        params.put("equipmentId", equipmentId);
        params.put("userId", touristId);
        Log.i("LoginService", "" + params.toString());
        return sNetInterface.communityHotInfo(params).compose(applySchedulers());
    }

    /**
     * @return
     * @method
     * @description 社区页面帖子列表
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<PostBean> communityPostList(String token, String equipmentId,String pageNo,String  touristId) {
        Params params = new Params();
        params.put("token", token);
        params.put("equipmentId", equipmentId);
        params.put("pageNo", pageNo);
        params.put("pageSize", 10);//一页返回多少条数据 默认10
        params.put("userId", touristId);
        Log.i("LoginService", "" + params.toString());
        return sNetInterface.communityPostList(params).compose(applySchedulers());
    }
    /**
     * @return
     * @method
     * @description 社区页面最新和热门帖子列表
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<PostBean> postNewAndHot(String token, String equipmentId,String pageNo,String  touristId,int searchType) {
        Params params = new Params();
        params.put("token", token);
        params.put("equipmentId", equipmentId);
        params.put("searchType", searchType);//查询热门或者最新的帖子  1最新 2热门
        params.put("pageNo", pageNo);
        params.put("pageSize", 10);//一页返回多少条数据 默认10
        params.put("userId", touristId);
        Log.i("LoginService", "" + params.toString());
        return sNetInterface.postNewAndHot(params).compose(applySchedulers());
    }
    /**
     * @return
     * @method
     * @description 帖子点赞
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<Result> postLikeAndUnLike(String token,String equipmentId,
                                                       String dynamicId,String type,String userId) {
        Params params = new Params();
        params.put("token", token);
        params.put("equipmentId", equipmentId);
        params.put("dynamicId", dynamicId);
        params.put("type", type);
        params.put("userId", userId);//
        Log.i("postLikeAndUnLike", "postLikeAndUnLike: --------"+params);
        return sNetInterface.postLikeAndUnLike(params).compose(applySchedulers());
    }
    /**
     * @return
     * @method
     * @description 帖子删除
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<Result> postDelete(String token,String equipmentId,
                                                       String dynamicId,String userId) {
        Params params = new Params();
        params.put("token", token);
        params.put("equipmentId", equipmentId);
        params.put("id", dynamicId);//帖子id
        params.put("userId", userId);//发帖人id
        Log.i("postLikeAndUnLike", "postLikeAndUnLike: --------"+params);
        return sNetInterface.postDelete(params).compose(applySchedulers());
    }
    /**
     * @return
     * @method
     * @description 帖子详情一级评论
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<CommentBean> postComment(String token, String equipmentId,
                                                      String dynamicId, String userId,String page) {
        Params params = new Params();
        params.put("token", token);
        params.put("equipmentId", equipmentId);
        params.put("dynamicId", dynamicId);//帖子id
        params.put("userId", userId);//发帖人id
        params.put("pageNo", page);
        params.put("pageSize", 10);//一页返回多少条数据 默认10
        //Log.i("postLikeAndUnLike", "postLikeAndUnLike: --------"+params);
        return sNetInterface.postCommentOne(params).compose(applySchedulers());
    }
    /**
     * @return
     * @method
     * @description 帖子详情2级评论
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<CommentBean> postCommentTwo(String token,String equipmentId,
                                                 String dynamicId,String userId,String page) {
        Params params = new Params();
        params.put("token", token);
        params.put("equipmentId", equipmentId);
        params.put("dynamicId", dynamicId);//评论id
        params.put("userId", userId);//发帖人id
        params.put("pageNo", page);
        params.put("pageSize", 10);//一页返回多少条数据 默认10
        //Log.i("postLikeAndUnLike", "postLikeAndUnLike: --------"+params);
        return sNetInterface.postCommentTwo(params).compose(applySchedulers());
    }
    /**
     * @return
     * @method
     * @description 帖子1级评论
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<Result>  submitPostComment(String token,String equipmentId,
                                                         String dynamicId,String userId,String content) {
        Params params = new Params();
        params.put("token", token);
        params.put("equipmentId", equipmentId);
        params.put("dynamicId", dynamicId);//帖子id
        params.put("levelUser1", userId);//评论人id
       // params.put("levelName1", name);//评论人id
        params.put("content", content);//评论内容
        Log.i("postLikeAndUnLike", "postLikeAndUnLike: --------"+params);
        return sNetInterface.postComment(params).compose(applySchedulers());
    }
   /* *
     * @return
     * @method
     * @description 帖子2级评论
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<Result> submitPostComment2(String token,String equipmentId,
                                                      String dynamicId,String userId,String content) {
        Params params = new Params();
        params.put("token", token);
        params.put("equipmentId", equipmentId);
        params.put("dynamicId", dynamicId);//一级评论id
        params.put("levelUser2", userId);//评论人id
      //  params.put("levelName2", name);//评论人id
        params.put("content", content);//评论内容
        Log.i("submitPostComment2", "postLikeAndUnLike: --------"+params);
        return sNetInterface.postComment(params).compose(applySchedulers());
    }
    /* *
     * @return
     * @method
     * @description 查看帖子详情信息
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<PostBean> selectDynamic(String token,String equipmentId,String userId,String id) {
        Params params = new Params();
        params.put("token", token);
        params.put("equipmentId", equipmentId);
        params.put("userId", userId);//
        params.put("id", id);//帖子id
        Log.i("submitPostComment2", "postLikeAndUnLike: --------"+params);
        return sNetInterface.selectDynamic(params).compose(applySchedulers());
    }
}
